<template>
  <div class="app-container">
    <el-form :inline="true" label-width="90px">
      <el-form-item label="服务商信息" >
        <el-input
          v-model="queryParams.keyword"
          placeholder="手机/真实姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="清算">
        <el-select v-model="queryParams.isclear" placeholder="清算" clearable size="small">
          <el-option
            v-for="dict in clearOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="创建时间">
        <el-date-picker
          v-model="daterange"
          size="small"
          style="width: 220px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <!--<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:post:add']">新增</el-button>-->
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="postList">
      <el-table-column label="服务商信息" align="center">
        <template slot-scope="scope">
          <span>{{(scope.row.channelNickname||'')+'/'+(scope.row.channelMobile||'')}}</span>
        </template>
      </el-table-column>
      <el-table-column label="类型" align="center" prop="type" :formatter="typeFormat"/>
      <el-table-column label="订单编号" align="center" prop="orderno" :show-tooltip-when-overflow="true"/>


      <el-table-column label="订单名称" align="center" prop="ordername"/>
      <el-table-column label="用户信息" align="center" :show-tooltip-when-overflow="true">
        <template slot-scope="scope">
          <span>{{(scope.row.nickname||'')+'/'+(scope.row.mobile||'')}}</span>
        </template>
      </el-table-column>
      <el-table-column label="美发师信息" align="center" :show-tooltip-when-overflow="true">
        <template slot-scope="scope">
          <span>{{(scope.row.stylistNickname||'')+'/'+(scope.row.stylistMobile||'')}}</span>
        </template>
      </el-table-column>
      <el-table-column label="门店信息" align="center" :show-tooltip-when-overflow="true">
        <template slot-scope="scope">
          <span>{{(scope.row.storename||'')+'/'+(scope.row.storeMobile||'')}}</span>
        </template>
      </el-table-column>
      <el-table-column label="关联金额" align="center" prop="fee">
        <template slot-scope="scope">
          <span>{{scope.row.joinAmount|currencyFilter}}</span>
        </template>
      </el-table-column>
      <el-table-column label="获取金额" align="center">
        <template slot-scope="scope">
          <span>{{scope.row.amount|currencyFilter}}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createtime" :show-tooltip-when-overflow="true"></el-table-column>
      <el-table-column label="是否清算" align="center" prop="isclear">
        <template slot-scope="scope">
          <span v-if="scope.row.isclear==='0'" class="text-danger">否</span>
          <span v-else class="text-success">是</span>
        </template>
      </el-table-column>
    </el-table>


    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


  </div>
</template>

<script>
  import {logList} from "@/api/channel/log";

  export default {
    data() {
      return {
        daterange: '',
        loading: true,
        total: 0,
        postList: [],
        typeOptions:[
          {dictLabel: '服务', dictValue: 1},
          {dictLabel: '商城', dictValue: 2},
        ],
        clearOptions:[
          {dictLabel: '否', dictValue: 0},
          {dictLabel: '是', dictValue: 1},
        ],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          keyword: undefined,
          isclear: undefined
        },
      };
    },
    created() {
      this.getList();
    },
    methods: {
      getList() {
        this.loading = true;
        logList(this.queryDateRange(this.queryParams, this.daterange)).then(response => {
          console.log(response.rows);
          this.postList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 岗位状态字典翻译
      typeFormat(row, column) {
        console.log(row);
        let options;
        if(column.property==='type'){
          options=this.typeOptions;
        }else if(column.property==='isclear'){
          options=this.clearOptions;
        }
        return this.selectDictLabel(options, row[column.property]);
      },
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      }
    }
  };
</script>
